package com.titaniume.rqbbitmq.util;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

/**
 * @ProjectName: rqbbitmq
 * @Package: com.titaniume.rqbbitmq.util
 * @ClassName: RabbitMqUtils
 * @Author: huangrenfei
 * @Description: 连接工具类
 * @Date: 2021/12/16 15:15
 * @Version: 1.0
 */
public class RabbitMqUtils {

    //得到一个连接的 channel
    public static Channel getChannel() throws Exception {
        //创建一个连接工厂
        ConnectionFactory factory = new ConnectionFactory();
        factory.setHost("118.190.135.94");
        factory.setUsername("admin");
        factory.setPassword("admin");
        Connection connection = factory.newConnection();
        Channel channel = connection.createChannel();
        return channel;
    }

}
